#include <iostream>
#include <unordered_map>

using namespace std;

typedef long long LL;

const int N = 2e5 + 10;

unordered_map<int, int> mp;

LL res;

int a[N];

int n, c;

int main()
{
	cin >> n >> c;
	
	for(int i = 0; i < n; i ++ )
	{
		cin >> a[i];
		mp[a[i]] ++ ;
	}
	
	for (int i = 0; i < n; i ++ )
	{
		int t = a[i] - c;
		res += mp[t];
	}
	
	cout << res << endl;
	
	return 0;
	
}